
// <copyright file="ComponentsConfigurationSection.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The components configuration section.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Configuration
{
    using System.Configuration;
    using System.Xml;

    using SubhadraSolutions.Sharp.Utils.Reflection;

    /// <summary>
    /// The components configuration section.
    /// </summary>
    public class ComponentsConfigurationSection : ConfigurationSection
    {
        #region Public Properties

        /// <summary>
        /// Gets the objects.
        /// </summary>
        public object[] Objects { get; private set; }

        #endregion Public Properties

        #region Methods

        /// <summary>
        /// The deserialize section.
        /// </summary>
        /// <param name="reader">
        /// The reader.
        /// </param>
        protected override void DeserializeSection(XmlReader reader)
        {
            if (this.Objects == null)
            {
                var doc = new XmlDocument();
                doc.Load(reader);
                this.Objects = ComponentBuilder.BuildComponentsFromXmlNode(doc.ChildNodes[0]);
            }
        }

        #endregion Methods
    }
}